﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace PSL.Package.System
{
    /// <summary>
    /// Provides all function for the console
    /// </summary>
    internal class PSL_Console
    {
        /// <summary>
        /// Init Console
        /// </summary>
        /// <param name="Runtime">Host</param>
        internal static void Init(PSLRuntime Runtime)
        {
            Action<string> printDelegate = Print;
            Runtime.AddMethod("Print", printDelegate);

            Action<dynamic> printLnDelegate = PrintLn;
            Runtime.AddMethod("PrintLn", printLnDelegate);

            Func<string> readLnDelegate = ReadLn;
            Runtime.AddMethod("ReadLn", readLnDelegate);

            ///Runtime.AddMethod("print", PSL_Console.Print);
            ///Runtime.AddMethod("println", PSL_Console.PrintLn);
            ///Runtime.AddMethod("read", PSL_Console.Read);
            ///Runtime.AddMethod("readln", PSL_Console.ReadLn);
        }

        /// <summary>
        /// Write to the console
        /// </summary>
        /// <param name="FunctionName"></param>
        /// <param name="Parameter"></param>
        /// <returns>nothing</returns>
        internal static void Print(string Text)
        {
            Console.Write(Text);
        }

        /// <summary>
        /// Write a line to the console
        /// </summary>
        /// <param name="FunctionName"></param>
        /// <param name="Parameter"></param>
        /// <returns>nothing</returns>
        internal static void PrintLn(dynamic Text)
        {
            Console.WriteLine(Text);
        }

        /// <summary>
        /// Read Line from Console
        /// </summary>
        /// <param name="FunctionName"></param>
        /// <param name="Parameter"></param>
        /// <returns>line-content</returns>
        internal static string ReadLn()
        {
            string cToReturn = Console.ReadLine();

            return cToReturn;
        }
    }
}
